import request from "@/utils/request";

// 获取周边分类
export const getRimCategory = (params: any) => {
  return request({
    url: `/peripheralProductsClassify/page`,
    method: "get",
    params
  });
};

// 新增周边分类
export const addRimCategory = (data: any) => {
  return request({
    url: `/peripheralProductsClassify/add`,
    method: "post",
    data
  });
};

// 新增分类接口
export const addPeripheralProductsClassify = (data: any) => {
  return request({
    url: `/peripheralProductsClassify`,
    method: "post",
    data
  });
};

// 删除周边分类
export const deletePeripheralProductsClassify = (id: string) => {
  return request({
    url: `/peripheralProductsClassify?id=${id}`,
    method: "delete"
  });
};

// 根据id查询周边详情
export const getRimCategoryById = (id: string) => {
  return request({
    url: `/peripheralProducts/byClassify?id=${id}`,
    method: "get"
  });
};

/******************************************************************************/

// 获取周边商品
export const getRimGoods = (params: any) => {
  return request({
    url: `/peripheralProducts/page`,
    method: "get",
    params
  });
};

// 修改周边分类
export const updatePeripheralProductsClassify = (data: any) => {
  return request({
    url: `/peripheralProductsClassify`,
    method: "put",
    data
  });
};

// 获取所有周边分类
export const getAllPeripheralProductsClassify = () => {
  return request({
    url: `/peripheralProductsClassify/all`,
    method: "get"
  });
};

// 上传图片
export const uploadImage = (data: FormData) => {
  return request({
    url: `/image`,
    method: "post",
    data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};

// 新增周边商品
export const addPeripheralProduct = (data: any) => {
  return request({
    url: `/peripheralProducts`,
    method: "post",
    data
  });
};

// 分页查询周边商品
export const getPeripheralProductsByPage = (params: any) => {
  return request({
    url: `/peripheralProducts/page`,
    method: "get",
    params
  });
};

// 更新周边商品
export const updatePeripheralProduct = (data: any) => {
  return request({
    url: `/peripheralProducts`,
    method: "put",
    data
  });
};

// 删除周边商品
export const deletePeripheralProduct = (ids: any[]) => {
  return request({
    url: `/peripheralProducts/del`,
    method: "delete",
    data: ids
  });
};

